package com.danco.training.property;


import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class PropertyReader {
	
	
	private Properties props;
	private static PropertyReader propertyReaderInstance;
	
	private PropertyReader(){

		props = new Properties();
	   

 
	 InputStream input = null;
		
		try {
			
			String filename = "bookshop.properties";
			input = getClass().getClassLoader().getResourceAsStream(filename);
	 
		  props.load(input);
		 
		  
		}
		  catch (FileNotFoundException e) {

		         System.out.println("File not found!");

		         e.printStackTrace();

		     }

		     catch (IOException e) {

		         System.out.println("IO Error!");

		         e.printStackTrace();

		     }   
		finally{
			try {
				input.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}

	 }

	public static PropertyReader getPropertyReaderInstance() {
		if (propertyReaderInstance == null){
			propertyReaderInstance = new PropertyReader();
		}
		return propertyReaderInstance;
	}

	public Properties getProps() {
		return props;
	}

	

		 
 

   
}

